home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / demos / 26 / general / prgfmt.doc < prev    next >
Encoding:
Internet Message Format  |  1986-06-19  |  3.9 KB

  1. Subject: Format of '.prg' files
  2.  
  3.  
  4.     I extracted the following info. from documents that came
  5. with the development system. I have only found the .prg (output
  6. of relmod) format, and not the .o format. The input of
  7. relmod is the standard cp/m-68K relocatable files, so I
  8. guess the .o format is the same as for cp/m-68K. I am not at
  9. all familiar with cp/m-68K, and i could not find anyting in the
  10. documents I have about the format of .o files. Maybe you are
  11. familiar with cp/m-68k or have access to the relevant cp/m-68k
  12. documents. Looking forward to your PD diss assmebler.
  13.  
  14. The format for a .prg file is as Follows (word = 16 bits). Output of
  15. relmod - 16 bit relocatable objects are not supported by Gem Dos.
  16.  
  17.     14 Word Header
  18.     Text Segment Image
  19.     Data Segment Image
  20.     Symbol Table (Optional)
  21.     Relocation Info (Optional)
  22.  
  23.  
  24. Header Format:
  25.     Byte    Size(words)    Contents
  26.     0    1        Contains 601A H Denoting Contiguous
  27.                 text, data and block storage segments
  28.     2    2        Size of Text Segment - Bytes
  29.     6    2        Size of Data Segment - Bytes
  30.     10    2        Size of Block Storage Segment - Bytes
  31.     14    2        Size of Symbol Table - Bytes
  32.     18    2        Reserved - Always Zero
  33.     22    2        Reserved - Always Zero
  34.                 (This is supposed to contain the
  35.                 Begining of the Text Segment and
  36.                 execution, but execution always begins
  37.                 at the top of the Text segement, hence 0)
  38.     26    1        If Zero then Relocation info IS
  39.                 present, No relocation info otherwise.
  40.                 Always Zero for Gem Dos.
  41.  
  42.  
  43. Symbol Table Format:
  44.     Each entry is 7 words.
  45.     
  46.     Byte    Size(words)    Contents
  47.     0    4        Name - zero padded to 8 characters
  48.     8    1        Type
  49.     10    2        Value
  50.  
  51.     Type            Value
  52.     defined            8000 H
  53.     equated         4000 H
  54.     global          2000 H
  55.     equated register    1000 H
  56.     external reference     800 H
  57.     data based reloc.     400 H
  58.     text based reloc.     200 H
  59.     bss  based reloc.     100 H
  60.  
  61.     where:
  62.       reloc. == relocatable
  63.  
  64.     A symbol with multiple characteristics has the bits OR'ed in
  65. the type field.
  66.  
  67.     The value field is the value of the symbol (address, register
  68. number, value of an expression or some other value). When the value
  69. field is non-zero AND the type field contains an External Symbol, the
  70. linker interprets the value to be a common region in which the size of
  71. the region is the value in the value field. Multiple such entries may
  72. be present and the size of the common that the linker ultimately
  73. decides on, is the greatest of the values, of the same name.
  74.  
  75.  The nm68 utility provided with the development system can be used to
  76. dump the symbol table.
  77.  
  78.  
  79. Relocation Information:
  80.     If  the last word in the header is Zero the relocation info is
  81.     present in the following format: (following symbol table if present)
  82.  
  83.     Byte    Size (BYTES)    Contents
  84.     0    4        Offset from the beginning of the Text
  85.                 Segment of the first longword needing
  86.                 relocation.
  87.     4    1        Relocation offset byte
  88.     5    1        "          "      "
  89.     .....
  90.  
  91.     xx    1        A byte containing Zero terminates
  92.  
  93.     Relocation offset byte - Gives the offset to the Next longword
  94. in the Text Segment to relocate (offset from the First Offset ) and so
  95. on. When an offset of Zero is encountered the relocation info
  96. is terminated. The bytes of Relocation offset give succeeding offsets.
  97. (so the smallest legal value is 4 (size of long word)). If a
  98. succeeding offset is greater than 254, then a byte containg One (1)
  99. will be encountered, signifying add 254 to the previous total.
  100.  
  101.     I hope that I explained the above clearly. I guess an example
  102. is appropriate to say what i mean.
  103.     Suppose that the first longword to be relocated is at offset
  104. 128 from the begining of the text segment. The next one is at offset
  105. 132 from the begining. The next is at offset 390 from the begining
  106. of the text segment (ie. 258 bytes from the second longword to be
  107. relocated ), Then the relocation info looks like
  108.  
  109.     byte    Size(BYTES)    Contents
  110.     0    4        128
  111.     4    1        4
  112.     5    1        1    (add 254)
  113.     6    1        4    (128 + 4 + 254 + 4 = 390)
  114.  
  115.     and so on.
  116.  
  117. I hope the above info help.
  118.